"""
文件操作
"""

f = open("C:/Users/WesleyWong/Desktop/temp/flash.txt", "r", encoding="UTF-8")
print(f"类型: {type(f)}")

# lines = f.readlines()
# print(lines)


for line in f:
    print(line)

f.close()

# 写入模式 会清空已经存在的文件内容
f1 = open("C:/Users/WesleyWong/Desktop/temp/flash.txt", "w", encoding="UTF-8")
f1.write("Python")
f1.flush()

f1.close()

try:
    f3 = open("./csv.txt", "r", encoding="UTF-8")
except FileNotFoundError as e:
    print(f"出现异常...{e.filename}")
else:
    print("无异常代码块")
finally:
    print("finally 代码块")
